<!--
 * @Description: 工单打印组件
 * @Autor: 何兴家
 * @Date: 2021-02-01 16:49:46
 * @LastEditors: 马毅
 * @LastEditTime: 2021-06-22 13:40:12
-->
<template>
  <div>
    <AjaxButton type="primary" :disabled="disabled" :click="handlePrint">打印工单</AjaxButton>

    <!-- 打印组件 -->
    <BasePrint ref="print" :showTopIcon="true" :title="dealerTitle" :data="printData" :isPreview="false" template="repair/repairOrder" />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { confirmAction, notifyAction, findFormItem, findTableItem } from '@/utils';
import { getAppId } from '@/assets/js/auth';
import { printRepairOrderOem } from '@/api/repair/repairManage/repairQuery/index.js';

export default {
  props: ['disabled', 'roNo', 'ownerCode'],
  mixins: [dictionary],
  data() {
    return {
      printData: {}, // 打印数据
      dealerTitle: ''
    };
  },
  mounted() {
    this.getTitle();
  },
  methods: {
    // 点击打印工单
    async handlePrint() {
      let res = await printRepairOrderOem({ roNo: this.roNo, ownerCode: this.ownerCode });
      if (res.resultCode == 200) {
        this.printData = res.data;
        this.$refs.print.EXCUTE_PRINT();
      }
    },
    getTitle() {
      let appId = getAppId();
      this.dealerTitle = '北京汽车售后维修业务委托书';
      if (appId == 'arcfox') {
        this.dealerTitle = '极狐汽车售后维修业务委托书';
      }
    }
  }
};
</script>

<style scoped></style>
